package com.flight.trans.adapter;

import android.content.Context;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.flight.trans.R;
import com.flight.trans.base.BaseRecyclerAdapter;
import com.flight.trans.base.BaseViewHolder;
import com.flight.trans.bean.EnterPortTakeBean.EnterPortTakeData;

import java.util.List;

/**
 * 出港提货
 */
public class EnterPortPickingAdapter extends BaseRecyclerAdapter<EnterPortTakeData> {

    private boolean IsChecked ;

    public EnterPortPickingAdapter(Context mContext, List<EnterPortTakeData> mList , boolean IsChecked) {
        super(mContext, mList);
        this.IsChecked = IsChecked ;
    }

    @Override
    public int setContentView() {
        return R.layout.adapter_enter_picking;
    }

    @Override
    protected void bindData(BaseViewHolder holder, EnterPortTakeData data, int position) {
        LinearLayout mLlContainerItem = holder.findViewById(R.id.mLlContainerItem);

        TextView mTvTakeNo = holder.findViewById(R.id.mTvTakeNo);
        TextView mTvOrderCount = holder.findViewById(R.id.mTvOrderCount);
        TextView mTvTotalCount = holder.findViewById(R.id.mTvTotalCount);
        TextView mTvTakePersonnel = holder.findViewById(R.id.mTvTakePersonnel);
        TextView mTvReceivingPerson = holder.findViewById(R.id.mTvReceivingPerson);
        TextView mTvCreatePerson = holder.findViewById(R.id.mTvCreatePerson);
        TextView mTvPickingPersonnel = holder.findViewById(R.id.mTvPickingPersonnel);
        TextView mTvPickingTime = holder.findViewById(R.id.mTvPickingTime);

        mTvTakeNo.setText(data.getConsigneeNo());
        mTvOrderCount.setText(String.valueOf(data.getOrderCnt()));
        mTvTotalCount.setText(String.valueOf(data.getRealNumber()));
        mTvCreatePerson.setText(data.getConsigneeCreateByName());
        mTvTakePersonnel.setText(data.getConsigneeName());
        mTvReceivingPerson.setText(data.getReceiverName());

        mTvPickingPersonnel.setVisibility(IsChecked ? View.GONE : View.VISIBLE);
        mTvPickingPersonnel.setText(data.getOutboundUser());
        mTvPickingTime.setVisibility(IsChecked ? View.GONE : View.VISIBLE);
        mTvPickingTime.setText(data.getOutboundTime());

        mLlContainerItem.setBackground(mContext.getDrawable(data.isLocked() ? R.color.color_red : R.drawable.selector_cyan_line));
        setOnItemClickListener(mLlContainerItem , position);
    }

    public void updateAdapter(List<EnterPortTakeData> mList , boolean IsChecked){
        this.IsChecked = IsChecked ;
        updateAdapter(mList);
    }
}
